#!/bin/bash

set -e          # exit on error
set -o pipefail # exit on pipeline error
set -u          # treat unset variable as error

SET_E=""
SET_U=""

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"

. "${SCRIPT_DIR}/minioslib" || exit 1
toggle_shell_options u
if [ -z ${BATCH} ]; then
    . "${SCRIPT_DIR}/config" || exit 1
fi
toggle_shell_options u

CMD=(chroot_setup_host install_core_packages chroot_finish_up)

# =============   main  ================

common_variables

console_colors

allow_root_only

#check_is_in_chroot

determine_command_range "${@}"

# Run commands within the defined range.
for ((ii = "${START_INDEX}"; ii < "${END_INDEX}"; ii++)); do
    "${CMD[ii]}"
done

echo -e "${BOLD}${LIGHTYELLOW}$0${ENDCOLOR} - ${LIGHTGREEN}Command completed successfully!${ENDCOLOR}"
